package com.thesis.service.impl;

import com.github.pagehelper.Page;
import com.thesis.dao.FoodMapper;
import com.thesis.entity.Food;
import com.thesis.service.FoodService;
import com.thesis.service.FoodService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class FoodServiceImpl implements FoodService {

    @Resource
    private FoodMapper FoodMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return FoodMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Food Food) {
        return FoodMapper.insert(Food);
    }

    @Override
    public int insertSelective(Food Food) {
        return FoodMapper.insertSelective(Food);
    }

    @Override
    public Food selectByPrimaryKey(Long id) {
        return FoodMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Food Food) {
        return FoodMapper.updateByPrimaryKeySelective(Food);
    }

    @Override
    public int updateByPrimaryKey(Food Food) {
        return FoodMapper.updateByPrimaryKey(Food);
    }

    @Override
    public List<Food> findPageList(Food Food) {
        return FoodMapper.findPageList(Food);
    }

    @Override
    public Page<Food> findPageListByVague(Food queryParam, String vagueParam) {
        return FoodMapper.findPageListByVague(queryParam,vagueParam);
    }

    @Override
    public Integer deleteBatchByIds(List<Integer> idList) {
        return FoodMapper.deleteBatchByIds(idList);
    }

    @Override
    public void saveOrUpdate(Food Food) {
        if(null == Food.getId()){
            FoodMapper.insert(Food);
        } else {
            FoodMapper.updateByPrimaryKey(Food);
        }
    }

    @Override
    public List<Food> findAll() {
        return FoodMapper.selectAll();
    }

    @Override
    public List<Food> selectClassListByProId(Long proId) {
        return FoodMapper.selectClassListByProId(proId);
    }

    @Override
    public List<Map<String, Object>> findAllByTime() {
        return FoodMapper.findAllByTime();
    }
}
